#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c;bool f=1;int a=0;
	while(!isdigit(c=getchar()))if(c=='-')f=0;
	do{a=(a<<1)+(a<<3)+(c^48);}while(isdigit(c=getchar()));
	return f?a:-a;
}
struct tra{
	int d,v,a;
}cars[100010];
int rec[100010];
struct part{
	int l,r;
}parts[100010];
bool operator<(part a,part b){
	return a.r<b.r||a.r==b.r&&a.l<b.l;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t=read();
	while(t--){
		int n=read(),m=read(),L=read(),V=read();
		for(int i=0;i<n;i++){
			cars[i].d=read();
			cars[i].v=read();
			cars[i].a=read();
		}
		for(int i=0;i<m;i++)
			rec[i]=read();
		int cnt=0,k_pa=0;
		for(int i=0;i<n;i++){
			int l=cars[i].d,r=L;
			if(cars[i].a<0){
				r=min(r,(int)floor(l-0.5*cars[i].v*cars[i].v/cars[i].a));
				int clbound=0,lr=m-1,crbound=m-1,rl=0,mid;
				while(clbound<=lr){
					mid=(clbound+lr)/2;
					if(rec[mid]<l)clbound=mid+1;
					else lr=mid-1;
				}
				while(rl<=crbound){
					mid=(rl+crbound)/2;
					if(rec[mid]>r)crbound=mid-1;
					else rl=mid+1;
				}
				int lbound=clbound,rbound=crbound;
				while(lbound<=rbound){
					mid=(lbound+rbound)/2;
					double v=sqrt(cars[i].v*cars[i].v+2*cars[i].a*(rec[mid]-cars[i].d));
					if(v<=V)rbound=mid-1;
					else lbound=mid+1;
				}
				if(rbound>=clbound){
					cnt++;
					parts[k_pa++]={clbound,rbound};
				}
			}
			else{
				int clbound=0,lr=m-1,crbound=m-1,rl=0,mid;
				while(clbound<=lr){
					mid=(clbound+lr)/2;
					if(rec[mid]<l)clbound=mid+1;
					else lr=mid-1;
				}
				while(rl<=crbound){
					mid=(rl+crbound)/2;
					if(rec[mid]>r)crbound=mid-1;
					else rl=mid+1;
				}
				int lbound=clbound,rbound=crbound;
				while(lbound<=rbound){
					mid=(lbound+rbound)/2;
					double v=sqrt(cars[i].v*cars[i].v+2*cars[i].a*(rec[mid]-cars[i].d));
					if(v<=V)lbound=mid+1;
					else rbound=mid-1;
				}
				if(lbound<=crbound){
					cnt++;
					parts[k_pa++]={lbound,crbound};
				}
			}
		}
		printf("%d ",cnt);
		sort(parts,parts+k_pa);
		int cused=0,usedend=-1;
		for(int i=0;i<k_pa;i++){
			if(usedend<parts[i].l){
				cused++;
				usedend=parts[i].r;
			}
		}
		printf("%d\n",m-cused);
	}
	return 0;
}
